package mxp

fun isIntStr(str: String): Boolean {
    return Regex("0[xX][0-9a-fA-F]*|$[0-9a-fA-F]*|0[bB][01]*|[0-9]*").matches(str)
}

fun str2int(str: String): Int {
    return when {
        str.startsWith("$") -> str.substring(1).toInt(16)
        str.startsWith("0x", true) -> str.substring(2).toInt(16)
        str.startsWith("0b", true) -> str.substring(2).toInt(2)
        else -> str.toInt(10)
    }
}